import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
import LoginView from '../views/LoginView.vue'
import IndexView from '../views/IndexView.vue'
import EchartsView from '../views/HomeChildren/EchartsView.vue'
import PermissionList from '../views/HomeChildren/PermissionList.vue'
import UserSum from "../views/HomeChildren/UserSum.vue"
import UserList from '../views/HomeChildren/UserList.vue'
import UserChange from '../views/HomeChildren/UserChange.vue'

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    redirect:'/login',
  },
  {
    path: '/login',
    name: 'login',
    component: LoginView
  },
  {
    path: '/index',
    name: 'index',
    component: IndexView,
    children: [
      {
        path: '/echarts',
        name: 'echarts',
        component: EchartsView,
        meta: {
          title: "数据显示"
        }
      },
      {
        path: '/permissionlist',
        name: 'permissionlist',
        component: PermissionList,
        meta: {
          title: "权限列表"
        }
      },
      {
        path: "/user",
        name: "user",
        component: UserSum,
        redirect: "/userlist",
        meta: {
          title: "住户信息"
        },
        children: [
          {
            path: '/userlist',
            name: 'userlist',
            component: UserList,
            meta: {
              classifyTitle: "住户信息",//分类标题
              title: "住户列表"
            }
          },
          {
            path: '/userupdate',
            name: 'userupdate',
            component: UserChange,
            meta: {
              classifyTitle: "住户信息",//分类标题
              title: "住户信息修改"
            }
          },
        ]
      }
    ]
  }
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
